package cn.anl.pojo.dto;

import cn.hutool.core.annotation.Alias;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;

import java.io.Serializable;
import java.util.List;
@Data
public class SysMenuDTO implements Serializable {
    private static final long serialVersionUID=1L;

    @Alias("menuId")
    private Long id;

    @ApiModelProperty(value = "父级ID")
    private Long parentId;


    @ApiModelProperty(value = "菜单名称")
    @Alias("menuName")//属性名不同拷贝解决方案
    private String title;


    @ApiModelProperty(value = "菜单排序")
    @Alias("orderNum")
    private Integer sort;

    @ApiModelProperty(value = "前端组件名称")
    @Alias("routeName")
    private String name;

    @ApiModelProperty(value = "前端图标")
    private String icon;

    @ApiModelProperty(value = "前端隐藏")
    @Alias("visible")
    private Integer hidden;

    @ApiModelProperty(value = "访问路径")
    private String path;

    @ApiModelProperty(value = "组件路径")
    private String component;

    @ApiModelProperty(value = "菜单类型")
    @Alias("menuType")
    private Integer type;

    @ApiModelProperty(value = "状态")
    private Integer status;

    //前端用以图标和面包屑
    @TableField(exist = false)
    private JSONObject meta;

    public JSONObject getMeta() {
        return Meta(this.getTitle(),this.getIcon());
    }

    //为meta构建JSONObejct对象值，前端用以图标和面包屑
    public JSONObject Meta(String title, String icon){
        SysMenuMeta menuMeta= new SysMenuMeta();
        menuMeta.setIcon(icon);
        menuMeta.setTitle(title);
        return JSONUtil.parseObj(menuMeta, true, true);
    }
    /**
     * 子节点
     */
    private List<SysMenuDTO> children;


    public void setChildren(List<SysMenuDTO> children) {
        this.children = children;  
    }  
  

}  
